import { Service } from "~/core/service";
import { NetService } from "~/util/net.service";
import { Inject, Debounce } from "~/core/decorator";
import { serviceManage } from "~/config/server";
import md5 from "md5";

export class LoginService extends Service {

  @Inject(NetService)
  private netService: NetService

  @Debounce()
  login({ userName, password }) {
    return this.netService.send(
      {
        server: serviceManage.loginController.login,
        data: {
          userName,
          password: md5(password)
        }
      }
    )
  }

  getUserInfoByToken() {
    return this.netService.send(
      {
        server: serviceManage.loginController.getUserInfoByToken
      }
    )
  }
}